<!--
 * @description  : 市管-考核计划检查详情
 * @descriptionDetail: 市管-考核计划检查详情
 * @copyright    : 浙江烟草
 * @author       : mc
 * @create       : 2022-08-09 14:43:02
-->
<template>
  <view>
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999">
    </theme-navbar>
    <!-- #endif -->
    <view class="content u-page">
      <form-section title="考核计划信息" :customStyle="customStyle"></form-section>
      <u-gap :marginRight="getGapMarginRowNumber()" :marginLeft="getGapMarginRowNumber()" :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
      <view class="info-lay">
        <u-row>
          <u-col span="7">
            <view class="info-title">
              考核计划名称
            </view>
            <view class="info-value">
              {{ examinInfo.planName }}
            </view>
          </u-col>
          <u-col span="5">
            <view class="info-title">
              被考核单位
            </view>
            <view class="info-value">
              {{ examinInfo.orgName }}
            </view>
          </u-col>
        </u-row>
        <u-row>
          <u-col span="7">
            <view class="info-title">
              企业字号
            </view>
            <view class="info-value">
              {{ examinInfo.companyName }}
            </view>
          </u-col>
          <u-col span="5">
            <view class="info-title">
              主体类型
            </view>
            <view class="info-value">
              {{ examinInfo.taskSubjectName }}
            </view>
          </u-col>
        </u-row>
        <u-row>
          <u-col span="7">
            <view class="info-title">
              经营地址
            </view>
            <view class="info-value">
              {{ examinInfo.businessAddr }}
            </view>
          </u-col>
          <u-col span="5">
            <view class="info-title">
              负责人
            </view>
            <view class="info-value">
              {{ examinInfo.managerName }}
            </view>
          </u-col>
        </u-row>
        <u-row>
          <u-col span="7">
            <view class="info-title">
              明察/暗访
            </view>
            <view class="sp-info-value">
              <z-dict-radio :dictType="$u.dic.DIC_KEYS.M_CHECK_MODE" ref="checkItem" :extFilterFun="extFilterFun" :disabled="true" v-model="examinInfo.checkMode"></z-dict-radio>
            </view>
          </u-col>
        </u-row>
      </view>
      <u-gap :marginRight="getGapMarginRowNumber()" :marginLeft="getGapMarginRowNumber()" :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
      <form-section title="检查项目" :customStyle="customStyle"></form-section>
      <view class="info-lay">
        <u-form-item labelWidth="250" label="是否公开摆卖" label-position="left">
          <view class="switch-lay">
            <u-switch v-model="examinInfo.isPublicSale" :disabled="true"></u-switch>
          </view>
        </u-form-item>
        <u-form-item labelWidth="250" v-show="examinInfo.checkMode != M_CH_MODE.SECRET_VISIT" label="是否售假" label-position="left">
          <view class="switch-lay">
            <u-switch v-model="examinInfo.isFakeSmoke" :disabled="true"></u-switch>
          </view>
        </u-form-item>
        <u-form-item labelWidth="250" v-show="examinInfo.checkMode != M_CH_MODE.SECRET_VISIT" label="是否售私" label-position="left">
          <view class="switch-lay">
            <u-switch v-model="examinInfo.isSmuggleSmoke" :disabled="true"></u-switch>
          </view>
        </u-form-item>
        <u-form-item labelWidth="250" v-show="examinInfo.checkMode != M_CH_MODE.SECRET_VISIT" label="是否售非" label-position="left">
          <view class="switch-lay">
            <u-switch v-model="examinInfo.isFfltSmoke" :disabled="true"></u-switch>
          </view>
        </u-form-item>
      </view>
      <u-gap :marginRight="getGapMarginRowNumber()" v-show="examinInfo.checkMode == M_CH_MODE.SECRET_VISIT" :marginLeft="getGapMarginRowNumber()" :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
      <form-section v-show="examinInfo.checkMode == M_CH_MODE.SECRET_VISIT" title="购买记录" :customStyle="customStyle"></form-section>
      <view class="info-lay u-m-b-30" v-show="examinInfo.checkMode == M_CH_MODE.SECRET_VISIT">
        <view class="card" v-for="(item, index) in examinInfo.buys" :key="index">
          <clientItem :client="item" @proList="proList"></clientItem>
        </view>
      </view>
      <u-popup mode="bottom" height="674rpx" v-model="brandShow">
        <brand-detail :brandObj="brandObj"></brand-detail>
      </u-popup>
    </view>
  </view>
</template>

<script>
import formSection from "@/components/form-section.vue";
import checkCheckService from "@/service/check/check.service";
import brandDetail from "./components/brandDetail"
import {ZDictRadio,} from '@/components';
import { M_CH_MODE, } from "@/service/check/mapping/enum.js";
import clientItem from "./components/clientItem.vue";
export default{
  components:{
    formSection,
    brandDetail,
    ZDictRadio,
    clientItem,
  },
  onLoad(opt) {
    let obj = this.getRouteParam();
    console.log(obj);
    // this.$set(this.examinInfo,"checkMode","01")
    this.init(obj.checkUuid)
  },
  data(){
    return {
      customStyle:{
      },
      checkInfo:{
        beCheckedOrg:"",
      },
      goodList:[],
      examinInfo:{
        isPublicSale:false,
        isFakeSmoke:false,
        isSmuggleSmoke:false,
        isFfltSmoke:false,
      },
      brandObj:{},
      brandShow:false,
      M_CH_MODE:M_CH_MODE,
    };
  },
  methods:{
    init(id){
      this.$modal.showLoading('加载中...');
      checkCheckService.samplingPlanClient({checkUuid:id,}).then(res => {
        if(res.success){
          this.$modal.hideLoading();
          this.examinInfo = res.bean;
          console.log(this.$refs.checkItem)
          this.examinInfo.isPublicSale = this.examinInfo.isPublicSale == 0 ? false : true;
          this.examinInfo.isFakeSmoke = this.examinInfo.isFakeSmoke == 0 ? false : true;
          this.examinInfo.isSmuggleSmoke = this.examinInfo.isSmuggleSmoke == 0 ? false : true;
          this.examinInfo.isFfltSmoke = this.examinInfo.isFfltSmoke == 0 ? false : true;
        }else{
          this.$modal.hideLoading();
          this.$u.toast(res.msg)
        }
      }).catch (err => {
        this.$modal.hideLoading();
        console.log(err)
      })
    },
    // 明察暗访类型过滤处理
    extFilterFun(itm,keyWord){
      if(keyWord == this.$u.dic.DIC_KEYS.M_CHECK_MODE){
        return itm.bcbCode != M_CH_MODE.RANDOM_SECRET;
      }
      return true;
    },
    getGapMarginRowNumber(){
      return "-" + this.$theme.cm_content_paddng_row.replace('rpx', '');
    },
    proList (itm) {
      console.log(itm)
      let buy = {buy:this.examinInfo.buys,};
      this.brandObj = {...itm,...buy,};
      this.brandShow = true;
    },
  },
}
</script>

<style scoped lang="scss">
	.info-title{
		font-size: 26rpx;
		width: 100%;
		margin-top: 10rpx;
		margin-bottom: 10rpx;
		color: $cm-form-item-label-color;
	}
	.content{
		padding: 0 $cm-content-paddng-row $cm-conent-padding-column $cm-content-paddng-row;
	}
	.info-value{
		font-size: 28rpx;
		color: $u-main-color;
		font-weight: 400;
		margin-top: 10rpx;
		margin-bottom: 10rpx;
	}
	.switch-lay{
		width: 100%;
		display: flex;
		flex-direction: row;
		justify-content: flex-end;
	}
	/deep/.u-td{
		height: auto !important;
	}
	.btn-lay{
		width: 100%;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-content: center;
		align-items: center;
		padding: 32rpx 0;
		uni-button{
			flex: 0.4;
		}
	}
  .card{
    margin: 14rpx -12rpx 18rpx -12rpx;
  }
</style>
